<?php
class WebsiteController extends CController {
	public function filters()
	{
		return array(
				'accessControl',
		);
	}
	public function actionIndex() {
		$this->pageTitle = 'Controller context test';
		
		$this->beginClip('beforeContent');
		echo 'Your IP is '.Yii::app()->request->userHostAddress;
		$this->endClip();
		$this->layout="column2";
		$this->render('index');
	}
	
	public function actionPage($alias) {
		echo "Page is $alias";
	}
	
	function hello()
	{
		if(!empty($_GET['name']))
			echo 'Hello, '.$_GET['name'].'!';
	}
	
	public function actionTest()
	{
		echo $this->createUrl('website/page', array('alias' => 'about'));
		echo $this->createAbsoluteUrl('website/page',array('alias' => 'test'));
	}
	
	public function actionOk() {
		Yii::app()->user->setFlash('success','Everything went  
         fine!');
		$this->redirect('index');
	}
	
	public function actionBad() {
		Yii::app()->user->setFlash('error','Everything went
         fine!');
		$this->redirect('index');
	}
	
	
	
	public function accessRules()
	{
		return array(
				array(
						'deny',
						'expression' => 'strpos($_SERVER[\'HTTP_USER_AGENT\'],
        \'MSIE\') !== FALSE',
						'message' => "You're using the wrong browser, sorry.",
				),
				array(
						'allow',
						'actions' => array('authOnly'),
						'users' => array('@'),
				),
				array(
						'allow',
						'actions' => array('ip'),
						'ips' => array('127.0.0.1'),
				),
				array(
						'allow',
						'actions' => array('user'),
						'users' => array('admin'),
				),
				array('deny'),
		);
	}
}